import axios, { AxiosRequestConfig } from 'axios'

import { IWaybillInfo } from '../interface'
import './__mock__'

/** 获取运单基础信息 */
export const apiGetWaybillInfo = async (
  waybillNo: string,
  signal?: AxiosRequestConfig['signal'],
): Promise<IWaybillInfo> => {
  return axios.post(`/tmsapi/waybill_record/waybillInfo`, { waybillNo }, { signal }).then(res => res.$data)
}

/** 处理异常 */
export const apiHandleAbnormal = async (req: {
  /** 运单号 */
  waybillNo: string
  /** 更新状态 0.标记为处理中 1.标记为已处理 */
  abnormalStatus: number
}) => {
  await axios.post(`/tmsapi/waybill_record/handleAbnormal`, req)
}

/** 处理归档 */
export const apiHandleArchive = async (req: {
  /** 运单号 */
  waybillNo: string
  /** 归档类型 1.归档 2.取消归档 */
  archiveType: number
}) => {
  await axios.post(`/tmsapi/waybill_record/archive`, req)
}
